package cn.elead.chaos.sso.server.web.sync;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import cn.elead.chaos.mybatils.web.controller.BaseController;
import cn.elead.chaos.sso.server.web.system.service.ISysDeptService;
import cn.elead.chaos.sso.server.web.system.service.ISysUserService;

/**
  *  同步Controller
 * 
 * @author luopeng
 * @date 2020-02-27 17:24:06
 */
@RestController
@RequestMapping("/sync")
public class SyncController extends BaseController {
	
	@Autowired
	private ISysUserService userService;
	
	@Autowired
	private ISysDeptService deptService;

	@GetMapping("/user")
	@ResponseBody
	@Scheduled(cron = "0 0 3 * * ?")
	public void syncUser() {
		userService.syncUser();
	}
	
	@ResponseBody
	@GetMapping("/password")
	@Scheduled(cron = "0 0 4 * * ?")
	public void initPassword() throws Exception {
		userService.initPassword();
	}

	
	//@Scheduled(cron = "0 30 5 * * ?")
	@ResponseBody
	@GetMapping("/dept")
	public void init() {
		deptService.init();
	}
}